//
//  AlertInputViewController.swift
//  hunan_ios_ldnydfuz
//
//  Created by yzd on 2019/5/17.
//  Copyright © 2019 ldnsm. All rights reserved.
//

import UIKit

class AlertInputViewController: UIViewController {
    public var tap: ((Double) -> Void)? = nil
    @IBOutlet weak var overView: UIView!
    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var input: UITextField!
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    required init() {
        super.init(nibName: nil, bundle: nil)
        view.backgroundColor = UIColor.clear
        self.providesPresentationContextTransitionStyle = true
        self.definesPresentationContext = true
        self.modalPresentationStyle = .custom
        
        // 初始化UI
        //        setupUIViews()
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
    }

    @IBAction func cancelTap(_ sender: Any) {
        sheetViewDismiss()
    }
    @IBAction func applyTap(_ sender: Any) {
        if let value = input.text?.trim , value != "" {
            self.tap?(Double(value)!)
        }
        }
    
    func sheetViewDismiss() {
        UIView.animate(withDuration: 0.25, animations: {
            self.overView.alpha = 0
            
        }) { (_) in
            self.dismiss(animated: false, completion: nil)
        }
    }
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
